﻿@{
    ViewBag.Title = "邮件通知";
    string email = ViewBag.email;
    List<SelectListItem> groupListItems = ViewBag.groupListItems;
    groupListItems.RemoveAt(0);//移除第一项
    int emailType = ViewBag.emailType;
}
@section HeaderContent{
    <script type="text/javascript" charset="utf-8" src="~/Scripts/ueditor/ueditor.config.js"></script>
    <script type="text/javascript" charset="utf-8" src="~/Scripts/ueditor/ueditor.all.min.js"></script>
    <script type="text/javascript" charset="utf-8" src="~/Scripts/ueditor/lang/zh-cn/zh-cn.js"></script>
}
<form id="form1" class="layui-form" url="EmailSave">
    @Html.AntiForgeryToken()
    <!--导航栏-->
    <div class="pageheader">
        <div class="page-bar">
            <ul class="page-breadcrumb">
                <li><a href="javascript:;"><i class="iconfont icon-home1"></i> 首页</a> </li>
                <li><a href="../channel/site_list">会员管理</a> </li>
                <li><a href="javascript:;">邮件通知</a> </li>
            </ul>
        </div>
    </div>
    <!--/导航栏-->
    <!--内容-->
    <div class="layui-fluid">
        <div class="layui-tab layui-tab-card">
            <ul class="layui-tab-title" id="floatHead">
                <li class="layui-this">批量邮件通知</li>
            </ul>
            <div class="layui-tab-content">
                <div class="layui-tab-item layui-show">
                    <div class="layui-form-item">
                        <label class="layui-form-label">输入类型</label>
                        <div class="layui-input-block">
                            @Html.RadioButton("rblemailType", 1, emailType == 1, new { title = "手动输入", @lay_filter = "btnSelected" })
                            @Html.RadioButton("rblemailType", 2, emailType == 2, new { title = "批量通知", @lay_filter = "btnSelected" })
                        </div>
                    </div>
                    <div id="emailType"></div>
                    <div class="layui-form-item">
                        <label class="layui-form-label">邮件标题</label>
                        <div class="layui-input-block">
                            @Html.TextBox("txtTitle", "", new { @class = "input normal", datatype = "*", nullmsg = "请填写邮件标题！" })
                            <span class="Validform_checktip">*</span>
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label">邮件内容</label>
                        <div class="layui-input-block">
                            @Html.TextArea("txtContent", "", new { style = "height:260px; width:100%;" })
                            <span class="Validform_checktip">*</span>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
    <!--/内容-->
    <!--工具栏-->
    <div class="page-footer">
        <div class="btn-wrap">
            <input type="submit" class="layui-btn iconfont icon-home1" id="btnSubmit" value="提交保存" />
            <button class="layui-btn layui-btn-warm icon-btn" name="btnReturn" onclick="javascript:history.back(-1);"><i class="layui-icon layui-icon-return"></i>返回上一页</button>
        </div>
    </div>
    <!--/工具栏-->
</form>
<script type="text/html" id="Group">
    <div class="layui-form-item">
        <label class="layui-form-label">会员组别</label>
        <div class="layui-input-block">
            @foreach (var kv in groupListItems)
            {
                <input type="checkbox" name="cblGroupId_@kv.Value" value="@kv.Value" title="@kv.Text">
            }
        </div>
    </div>
</script>
<script type="text/html" id="Emails">
    <div class="layui-form-item">
        <label class="layui-form-label">邮箱地址</label>
        <div class="layui-input-block">
            @Html.TextArea("txtEmailList", email, new { @class = "input", style = "padding-left: 10px;width:98%;height:150px;", tip = "以英文“,”逗号分隔开" })
            <span class="Validform_checktip">*请填写正确的邮箱地址，多个邮箱地址号以“,”号分隔开</span>
        </div>
    </div>
</script>
@section Scripts{
    <script type="text/javascript">
        layui.use(['form', 'validform','jqueryform','element'], function () {
            var form = layui.form, $ = layui.jquery;
            //初始化表单验证
            $("#form1").initValidform('#btnSubmit', 1);

            //编辑器
            UE.getEditor('txtContent');

            form.on('radio(btnSelected)', function (data) {
                changeQT(data.value);
            });
            setTimeout(function () {
                changeQT(@emailType);
            }, 50);
            function changeQT(value) {
                $("#emailType").html('');
                if (value == 1) {
                    $("#emailType").html($("#Emails").html());
                } else {
                    $("#emailType").html($("#Group").html());
                }
                form.render();
            }
        });
    </script>
}